package merisis.experiments.gcs;

import java.util.Arrays;
import java.util.Random;

public class ExperimentUtil {

	public static long[] genRandArray(long minval, long maxval, int len) {

		long[] a = new long[len];

		long scope = maxval - minval + 1;
		Random rand = new Random();

		int count = 0;
		while (count < len) {

			long elem = minval + rand.nextInt((int) scope);

			a[count] = elem;

			count++;
		}

		Arrays.sort(a);

		return a;
	}

	public static long[] genPolynomial2(int start, int size) {

		long[] a = new long[size];

		for (int i = 0; i < size; i++) {
			long n = start + i;
			a[i] = n * n;
		}
		return a;
	}

	public static void print(long[] a) {

		StringBuilder sb = new StringBuilder();
		if (a == null || a.length == 0)
			System.out.println("[]");

		for (int i = 0; i < a.length; i++) {
			if (i % 5 == 0) {
				sb.append('\n');
				sb.append(String.format("[%03d] ", i));
			} else {
				sb.append(',');
			}
			sb.append(String.format("%10d", a[i]));
		}
		System.out.println("" + sb.toString());
	}
}
